package legumes.client.services.callbacks;

import legumes.client.services.LegumesServicesHelper;
import legumes.client.services.util.rpc.SequencableRPCCall;
import legumes.shared.domain.Customer;

public class AddCustomerCallback extends SequencableRPCCall<Customer> {

	private Customer customerToAdd;
	private Customer addedCustomer;

	public AddCustomerCallback(Customer customerToAdd_) {
		customerToAdd = customerToAdd_;
	}

	@Override
	protected void doCall() {
		LegumesServicesHelper.LEGUMES_SERVICES.addCustomer(customerToAdd, this);
	}

	@Override
	public void onSuccess(Customer result_) {
		addedCustomer = result_;
		callNext();
	}

	public Customer getAddedCustomer() {
		return addedCustomer;
	}

}
